package com.woniu.controller;


import com.woniu.common.CommonResult;
import com.woniu.pojo.Business;
import com.woniu.pojo.Businessdto;
import com.woniu.pojo.Propertypaydto;
import com.woniu.service.BussinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/bussiness")
public class BusinessController {

    @Autowired
    private BussinessService bussinessService;


    @GetMapping("/selectBussiness")
    public  @ResponseBody CommonResult selectBussinesslist()
    {
        Integer userid=1;
        try {
            List<Businessdto> businesses=bussinessService.selectBusinessByUserId(userid);
            return CommonResult.success(businesses);
        } catch (Exception e){
            e.printStackTrace();
            return  CommonResult.failed("获取数据失败");
        }
    }

    @GetMapping("/list/{shopid}")
    public  @ResponseBody  CommonResult selectBussinessService(@PathVariable("shopid")Integer shopid)
    {
        System.out.println(shopid);
        try {
            List<Propertypaydto> bussinessservice=bussinessService.selectServiceByShopId(shopid);
            return  CommonResult.success(bussinessservice);
        } catch (Exception e) {
            e.printStackTrace();
            return  CommonResult.failed("请求数据失败");
        }

    }

}
